<style>
    .modal-content{height:460px;}
</style>
<div class="col-lg-12" style="margin-left: 10px;width: 500px; height: auto; margin-top:20px;">
    <form id="AppFormAdd" action="{:url('sun/menu/menuAdd')}" method="post" class="form-horizontal" data-bv-message="" data-bv-feedbackicons-valid="glyphicon glyphicon-ok" data-bv-feedbackicons-invalid="glyphicon glyphicon-remove" data-bv-feedbackicons-validating="glyphicon glyphicon-refresh">
        <div class="form-group">
            <label class="col-lg-3 control-label">菜单上级 :<sup>*</sup></label>
            <div class="col-lg-9">
                <select name="menu_pid" id="menu_pid" class="form-control">
                    <option value="0">一级菜单</option>
                    {volist name="topMenuList" id="vo"}
                    <option value="{$vo.id}">{$vo.name}</option>
                    {/volist}
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-lg-3 control-label">菜单名称 :<sup>*</sup></label>
            <div class="col-lg-9">
                <input class="form-control"  type="text" name="name" placeholder="菜单名" value="" data-bv-notempty />
            </div>
        </div>
        <div class="form-group">
            <label class="col-lg-3 control-label">控制器/方法 :<sup>*</sup></label>
            <div class="col-lg-9">
                <input class="form-control" type="text" name="url" placeholder="控制器/方法" value="" data-bv-notempty />
            </div>
        </div>

        <div class="form-group" id="parentIcon">
            <label class="col-lg-3 control-label">菜单图标 :</label>
            <div class="col-lg-9">
                <input class="form-control" type="text" name="icon" placeholder="导航栏小图标 如Home" value="">
            </div>
        </div>

        <div class="form-group">
            <label class="col-lg-3 control-label">菜单排序 :</label>
            <div class="col-lg-9">
                <input class="form-control" type="text" name="menu_order" placeholder="排序" value="" />
            </div>
        </div>

        <div class="form-group">
            <label class="col-lg-3 control-label">菜单描叙 :</label>
            <div class="col-lg-9">
                <textarea class="form-control" rows="3" name="desc" placeholder="菜单描叙内容" ></textarea>
            </div>
        </div>

        <div class="form-group">
            <div class="col-lg-offset-6 col-lg-4">
                <button id="saveButton" style="margin-top: 5px;" class="btn btn-primary" type="submit">保存</button>
            </div>
        </div>
    </form>
</div>
<script type="text/javascript">

    /**
     * 父级菜单才填写导航栏小图标
     */
    $(function(){
        $("#menu_pid").change(function(){
            var value = $(this).val();
            if(value == 0){
                $("#parentIcon").show();
            }else{
                $("#parentIcon").hide();
            }
        });
    });


    $('#AppFormAdd').bootstrapValidator({
        submitHandler: function(validator, form, submitButton) {

            var formNode = validator.$form.context;

            var tourl = formNode.action;

            var data = $(formNode).serialize();

            $.post(tourl, data, function(json) {

                if (json.code == 1) {
                    $.App.alert('success', json.msg);
                    $('.close').click();
                    $('#refresh-toggler').click();
                } else {
                    $.App.alert('danger', json.msg);
                }
            })
        }
    });
</script>